#ifndef USER_H
#define USER_H
#include <iostream>
#include <string>
#include "vendmach.h"
#include "drink.h"
using namespace std;

/*
    人类，基类派生出用户类和补货员类
*/
class person {
public:
    string name;
    int age;
    person(string name, int age) {
        this->name = name;
        this->age = age;
    }
    virtual void drink(Drink *d,int num) = 0; // 虚函数，子类必须实现
};
/*
    用户类，继承自person类，
*/
class user : public person {
public:
    user(string name, int age) : person(name, age) {}
    void drink() {
        cout << "User " << name << " is drinking." << endl;
    }

    /*按按钮函数，在收到调用指令后按按钮*/
};
/*
    通过友元访问权限，补货员类可以访问vendmach类的私有成员变量，并调用其方法，进行补drink操作
*/
class replenisher : public person {
public:
    replenisher(string name, int age) : person(name, age) {}
    void drink() {
        cout << "Replenisher " << name << " is replenishing." << endl;
    }
    void replenish(vendmach &vm) {
        cout << "Replenisher " << name << " is replenishing the vending machine." << endl;
        vm.replenish();
    }
    friend void replenish_machine(vendmach &vm, replenisher &r); // 友元函数，可以访问vendmach类的私有成员变量
};

#endif // USER_H



